package com.sl.plugin.step.json;

import com.sl.core.domain.dto.JsonFieldDefine;
import com.sl.core.utils.JsonUtil;
import com.sl.core.engine.meta.ProcessCompDescriptorService;
import com.sl.core.engine.meta.impl.AbstractProcessCompDescriptor;
import com.sl.core.engine.meta.row.ProcessRowDescriptor;
import lombok.Getter;

import java.util.List;
import java.util.Map;

/**
 *
 */
@Getter
public class JsonAssignCompDescriptor extends AbstractProcessCompDescriptor<
        JsonAssignComp, JsonAssignCompContext> implements ProcessCompDescriptorService {


//    @Override
//    protected ProcessCompService getComp() {
//        return new JsonInputComp(this);
//    }
//
//    @Override
//    public ProcessCompContextService getContext() {
//        return new JsonInputCompContext();
//    }

    @Override
    public void loadDescriptor(Map<String, Object> map) {

    }


    @Override
    public ProcessRowDescriptor getResultDescriptor(ProcessRowDescriptor rowDescriptor) {

        List<Map<String, Object>> listMapAttr = getListMapAttr("output.params");
        List<JsonFieldDefine> inputFieldDefine = JsonUtil.toList(listMapAttr, JsonFieldDefine.class);
        ProcessRowDescriptor processRowDescriptor = new ProcessRowDescriptor(rowDescriptor);

        processRowDescriptor.mergeJsonDefine(inputFieldDefine);
        return processRowDescriptor;
    }


}
